<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/layui/layui.js"></script>
    <link rel="stylesheet" href="../js/layui/css/layui.css"/>
</head>
<body>
    <!--<div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm"  onclick="openAddProductDialog()">新增</button>
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData" onclick="delManyProduct()">批量删除</button>
    </div>-->
    <table class="layui-hide" id="companyTable" lay-filter="companyFilter"></table>
</body>
<script>
    var table;
    var $;
    layui.use(['table'], function() {
        table = layui.table;
        $ = layui.jquery;
        table.render({
            id:'companyTableId',
            elem: '#companyTable',
            fit: true,
            url: '../company/companyMessage', //数据接口
            cols: [
                [ //表头
                    {type:'checkbox', fixed:'left'},
                    {field:'userName', title:'账号', align: 'center'},
                    {field:'comName', title:'公司名称', align: 'center'},
                    {field:'address', title:'公司地点', align:'center'},
                    /*{field:'zhiZhao', title:'公司执照', align:'center', sort:true, templet:function(data){
                        return '<img src="'+data+'" width="60px" height="60px">'
                    }},*/
                    {field:'zhiZhaoHao', title:'执照编号', align:'center'},
                    {fixed:'right',title: '操作',align:'center', toolbar:'#toolbar'}
                ]
            ]
        });
        table.on('tool(companyFilter)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                openEditDialog(data.id);
            }
        })
    })

    //打开修改弹框
    function openEditDialog(id){
        layer.open({
            type:2,
            title:'编辑资料',
            area: ['800px', '500px'],
            fixed: false, //不固定
            maxmin: true,
            content: '../page/toDatum',
            btn:['保存'],
            success: function(layero,index){
                $.ajax({
                    url:'../company/addDatum',
                    data:{id:id},
                    dataType:'json',
                    type:'post',
                    success:function (data) {
                        var iframeWin=window[layero.find("iframe")[0]["name"]];
                        iframeWin.editForm(data);
                    }
                })
            },
            btn1:function (index,layero) {
                var iframeWin=window[layero.find("iframe")[0]["name"]];
                iframeWin.saveCompanyMessage();
                layer.close(index);
                table.reload("companyTableId",{})
            }
        })
    }
</script>
<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
</html>